﻿<UserControl x:Class="LayoutManager.Modules.Views.MenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Views="clr-namespace:LayoutManager.Modules.Views"
             >
    <UserControl.Resources>
        <SolidColorBrush Color="#FFb5c8e1"
                         x:Key="MenuBorderColor"></SolidColorBrush>
        <SolidColorBrush Color="#FF252525"
                         x:Key="MenuItemTextColor"></SolidColorBrush>
        <SolidColorBrush Color="#FFb5c8e1"
                         x:Key="MenuItemHoverColor"></SolidColorBrush>
        <Style TargetType="{x:Type MenuItem}"
               x:Key="MenuItemStyle">
            <Setter Property="Command"
                    Value="{x:Static Views:MenuViewModel.LoadLayoutCommand}" />
            <Setter Property="CommandParameter"
                    Value="{Binding}" />
            <Setter Property="MenuItem.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border HorizontalAlignment="Stretch"
                                x:Name="Root"
                                Padding="2">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                                <Border HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        x:Name="ImageWrapper"
                                        Grid.RowSpan="2"
                                        Background="Transparent"
                                        Grid.Column="0">
                                    <Image Width="24"
                                           Height="24"
                                           Grid.RowSpan="2"
                                           VerticalAlignment="Top"
                                           Source="{Binding Path=ThumbnailSource}"></Image>
                                </Border>
                                <Border Grid.Column="1"
                                        Grid.RowSpan="2"
                                        x:Name="NameWrapper"
                                        HorizontalAlignment="Stretch"
                                        Padding="1" />
                                <TextBlock Text="{Binding Path=Fullname}"
                                           x:Name="Name"
                                           Grid.Column="1"
                                           Grid.Row="0"
                                           FontWeight="700"
                                           Margin="10,0,5,3"
                                           Foreground="{StaticResource MenuItemTextColor}"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch" />
                                <TextBlock Text="{Binding Path=Description}"
                                           x:Name="Description"
                                           Grid.Column="1"
                                           Grid.Row="1"
                                           Foreground="{StaticResource MenuItemTextColor}"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="Stretch"
                                           Margin="10,0,5,10" />
                                <Border x:Name="DisabledOverlay"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        Grid.Column="0"
                                        Grid.RowSpan="2"
                                        Grid.ColumnSpan="2"
                                        Background="{StaticResource MenuBorderColor}"
                                        Opacity="0"></Border>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver"
                                     Value="true"
                                     SourceName="Root">
                                <Trigger.Setters>
                                    <Setter Property="Background"
                                            TargetName="NameWrapper"
                                            Value="{StaticResource MenuItemHoverColor}"></Setter>
                                    <Setter Property="Background"
                                            TargetName="Name"
                                            Value="{StaticResource MenuItemHoverColor}"></Setter>
                                    <Setter Property="Background"
                                            TargetName="Description"
                                            Value="{StaticResource MenuItemHoverColor}"></Setter>
                                    <Setter Property="Background"
                                            TargetName="ImageWrapper"
                                            Value="{StaticResource MenuItemHoverColor}"></Setter>
                                </Trigger.Setters>
                            </Trigger>
                            <Trigger Property="IsEnabled"
                                     Value="false"
                                     SourceName="Root">
                                <Trigger.Setters>
                                    <Setter Property="Opacity"
                                            TargetName="DisabledOverlay"
                                            Value="0.7"></Setter>
                                    <Setter Property="Foreground"
                                            TargetName="Name"
                                            Value="{StaticResource MenuBorderColor}"></Setter>
                                </Trigger.Setters>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Menu HorizontalAlignment="Stretch"
              HorizontalContentAlignment="Stretch">
            <MenuItem Header="Add Layout"
                      Command="{x:Static Views:MenuViewModel.AddLayoutCommand}" />
            <MenuItem Header="Layouts"
                      ItemContainerStyle="{StaticResource MenuItemStyle}"
                      ItemsSource="{Binding Path=Layouts}"></MenuItem>
        </Menu>
    </Grid>
</UserControl>
